<?php
/**
 * Installer tables creation page
 *
 * @copyright		The XOOPS project http://www.xoops.org/
 * @license			http://www.fsf.org/copyleft/gpl.html GNU General Public License (GPL)
 * @package			installer
 * @since			2.0.18
 * @version			$Id: page_tablescreate.php 603 2006-07-01 22:27:32Z skalpa $
 *
 * @author			Haruki Setoyama  <haruki@planewave.org>
 * @author			Kazumi Ono <webmaster@myweb.ne.jp>
 * @author			Skalpa Keo <skalpa@xoops.org>
 * @author			dugris <dugris@frxoops.org>
**/

require_once 'common.inc.php';
if ( !defined('XOOPS_INSTALL') ) { die('XOOPS Custom Installation die'); }

$wizard->setPage( 'tablescreate' );
$pageHasForm = true;
$pageHasHelp = false;

$vars =& $_SESSION['settings'];

include_once "../mainfile.php";
include_once './class/dbmanager.php';
$dbm = new db_manager();

if ( !$dbm->isConnectable() ) {
	$wizard->redirectToPage( '-2' );
	exit();
}

$process = '';
if ( !$dbm->tableExists( 'users' ) ) {
	$process = 'create';
}

if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
	// If there's nothing to do: switch to next page
	if ( empty( $process ) ) {
		$wizard->redirectToPage( '+1' );
		exit();
	}
    $tables = array();
    $result = $dbm->queryFromFile( './sql/' . XOOPS_DB_TYPE . '.structure.sql' );
    $content = $dbm->report();
    include 'install_tpl.php';
	exit();
}

    ob_start();

if ( $process == 'create' ) {
	echo "<div class='x2-note confirmMsg'>" . READY_CREATE_TABLES . "</div>";
} else {
	$pageHasForm = false;
	echo "<div class='x2-note confirmMsg'>" . XOOPS_TABLES_FOUND . "</div>";
}

$content = ob_get_contents();
ob_end_clean();
include 'install_tpl.php';

?>
